<%@page import="org.blog.messages.BlogMessage"%>
<%@page import="org.blog.logic.UserLogic"%>
<%@page import="org.blog.beans.Entry"%>
<%@page import="org.blog.beans.Comment"%>
<%@page import="org.blog.logic.BlogLogic"%>
<%@page import="org.blog.beans.Blog"%>
<%@page import="java.util.ArrayList"%>
<%@page import="org.blog.messages.UserSettingsMessage"%>
<%@page import="org.blog.controller.UserController"%>
<%@page import="org.blog.beans.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1" %>
<%@ page errorPage="../jsp/exceptionHandler.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<jsp:include page="../jsp/cssChoose.jsp" />

<script type="text/javascript" src="js/validation.js"></script>

<title><%= request.getParameter("title") %></title>
</head>
<body>
 	<div id = "container"> 	
 	 	
 	<%Blog blog = (Blog)session.getAttribute("blog"); %> 	
 	 	
 	<jsp:include page="../jsp/header.jsp">
 		<jsp:param value="<%= blog.getName() %>" name="title"/>
 	</jsp:include>
 		<div id="texts">
	<jsp:include page="../jsp/menu.jsp"/>	
		
		<div id = "content">	
			
			<%
			Entry entry = (Entry)session.getAttribute("entry");
			%>
			<% BlogMessage bm = (BlogMessage)request.getAttribute("message"); 
				   if(bm == null) bm = new BlogMessage();
			%>
			<h1><%= entry.getTitle() %></h1>
			<h2><%= entry.getText() %></h2>
			<%
			for(Comment c : entry.getComments()) { 
				String user = "Gosc";
				if(c.getUserId() > 0)
					user = UserLogic.getInstance().getUser(c.getUserId()).getLogin();
			%>		
				<div class = entry><%= user +": "+ c.getText() %></div>
			<%} %>
		
			<form name = "addComment" method = "post" action = "EntryServlet?do=addComment&id=<%= entry.getId()%>">
								
				komentarz: <br/>
				<textarea rows="5" cols="30" name = "text" ></textarea> <br/>
				<div id = "textE" class = "error"><%= bm.getComment() %></div>
					
				<button type = "submit">dodaj</button>
					
			</form>
					
</div>
	</div>
		<jsp:include page="../html/footer.html"/>
						

	</div>
	
</body>
</html>